<template>
  <div id="app">
    <h2>测试题</h2>
   
      <SubjectItemVue v-for="(item,index) in list" :key="index" :data="item" @result="item.result=$event"></SubjectItemVue>
  
    <div>
      <FlagItem v-for="(item,index) in list" :key="index" :data="item.result" >{{ index+1 }}:{{ item.result }}</FlagItem>
    </div>
  </div>
</template>

<script>
import SubjectItemVue from './components/SubjectItem.vue.vue'; 
import FlagItem from './components/FlagItem.vue';
export default {
  components: {
    SubjectItemVue,
    FlagItem
  },
  data(){
   return{
    list:[]
   } 
  },
  created()
{
this.getList()
} , methods:{
    getList(){
      for(let i=0;i<5;i++){
      const num1=Math.floor(Math.random() * 10)
       const num2=Math.floor(Math.random() * 10)
       this.list.push({
        'num1':num1,
        'num2':num2,
        'result':null
       })
      }
    },
  }

}

</script>

<style>
body {
  background-color: #eee;
}

#app {
  background-color: #fff;
  width: 500px;
  margin: 50px auto;
  box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.5);
  padding: 2em;
}
</style>